import {Injectable} from '@angular/core';
import {ExtendHttpService} from "../../common/extend-http.service";
import {Router} from "@angular/router";

@Injectable()
export class LoginService {

  constructor(
    private extendHttp: ExtendHttpService,
    private router: Router
  ) {}

  requestData(): any {
    return this.extendHttp.get('/merchantApp/basics/loginInfo/getInfo', {}).map(data => {
      let body = data.json();
      if (body.code == '0') {
        this.router.navigate(['/main']);
      } else if (body['code'] == '-2001') {
        return true;
      } else {
        return false;
      }
    });
  }

}
